'use strict';
const db = uniCloud.database()
const $ = db.command.aggregate
exports.main = async (event, context) => {
	//event为客户端上传的参数
	const {
		username
	} = event
	const userInfo = await db.collection('uni-id-users').where({
		username: username
	}).get()
	const collect = userInfo.data[0].collect
	const goods = await db.collection('goods-list').aggregate()
		.addFields({
			is_like: $.in(['$_id', collect])
		}).end()
	// const res = await goods.get(event)
	//返回数据给客户端
	return goods
};
